<!DOCTYPE html>
<html lang="en">
<head>
	<title> ${blogger.nickname} - @${blogger.uniqueId} TikTok Analytics | GugeeData</title>
	<meta charset="UTF-8">
	<meta name="viewport"
	      content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
	<meta name="baidu-site-verification" content="7Kv8mw99Qh"/>
	<meta name="google-site-verification" content="YPMm_1_f59WXKSd04F1LGCjKeDGVrf_ajrylNKEDtqg"/>
	<meta name="keywords"
	      content="${blogger.nickname}, @${blogger.uniqueId}, Creator of TikTok, TikTok Usernames, TikTok Search, TikTok Videos, TikTok Analytics">
	<meta name="description"
	      content="Let's check out ${blogger.nickname} TikTok analytics report on GugueeData, a professional TikTok analytics tool, that helps you find creators of TikTok, hot videos, popular songs and trending hashtags.">
	<meta property="og:title" content="${blogger.nickname} - @${blogger.uniqueId} TikTok Analytics | GugeeData">
	<meta property="og:description"
	      content="${blogger.nickname} TikTok Analytics on GugeeData,a professional TikTok analytics tool, that helps you find creators of TikTok, hot videos, popular songs and trending hashtags.">
	<meta name="twitter:title" content="${blogger.nickname} - @${blogger.uniqueId}  TikTok Analytics | GugeeDataa">
	<meta name="twitter:description"
	      content="${blogger.nickname} TikTok Analytics on GugeeData, a professional TikTok analytics tool, that helps you find creators of TikTok, hot videos, popular songs and trending hashtags.">

	<link rel="icon" href="${request.contextPath}/static/img/favicon.ico" type="image/x-icon"/>
	<link rel="shortcut icon" href="${request.contextPath} /static/img/favicon.ico" type="image/x-icon"/>
	<link rel="stylesheet" href="${request.contextPath}/static/css/reset.css">
    <#if isMobile == false>
		<link rel="stylesheet" href="${request.contextPath}/static/plugins/layui/layui.css">
		<!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <#--        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">-->
		<link rel="stylesheet" href="${request.contextPath}/static/css/common.css">
		<link rel="stylesheet" href="${request.contextPath}/static/css/tiktoker.css">
    <#else>
		<link rel="stylesheet" href="${request.contextPath}/static/css/mobile/common.css">
		<link rel="stylesheet" href="${request.contextPath}/static/css/mobile/tiktoker.css">
    </#if>
	<link href="https://fonts.googleapis.com/css2?family=Oswald:wght@500&display=swap" rel="stylesheet">
    <#include "../component/facebookPixel.ftl">
</head>
<body>
<#include "../header_new.ftl">
<#if isMobile == false>
	<main>
        <#include './top.ftl'>
		<section class="wrap wrap-tab">
			<ul class="tab">
				<li class="tab-item is-active" onclick="changetab(0)">Videos</li>
				<li class="tab-item" onclick="changetab(1)">Key Data</li>
				<li class="tab-item" onclick="changetab(2)">Audience Demographics</li>
				<li class="tab-item" onclick="changetab(3)">Post Analytics</li>
			</ul>
			<div class="line"></div>
            <#include './videos.ftl'>
            <#include './keyData.ftl'>
            <#include './audience.ftl'>
            <#include './postAnalytics.ftl'>
		</section>
		<section class="wrap-more">
			<h2>Explore More TikTokers</h2>
			<div class="tiktoker-list">
                <#list bloggers as item>
					<a href="${contextPath}/tiktoker/${item.uniqueId}">
						<div class="tiktoker-item wrap">
							<div class="item-user">
								<img src="${item.avatar}">
								<div class="user-name">${item.nickname}</div>
								<div class="user-id">${item.uniqueId}</div>
							</div>
							<div class="item-data">
								<div>
									<div class="item-label">Followers</div>
									<div class="item-num">${item.followerCount}</div>
								</div>
								<div>
									<div class="item-label">Likes</div>
									<div class="item-num">${item.likeCount}</div>
								</div>
							</div>
						</div>
					</a>
                </#list>
			</div>
		</section>
        <#if login == false>
			<section class="wrap-link">
				<a href="javascript:;" onclick="toLogin()">
					<div class="btn">
						Login to view more
					</div>
				</a>
			</section>
        </#if>
	</main>
    <#include "../footer.ftl">
<#else>
    <#include './mobile/index.ftl'>
</#if>
<script src="//at.alicdn.com/t/font_1880456_wxrmqb8capj.js"></script>
<script src="${request.contextPath}/static/plugins/jquery.min.js"></script>
<script src="${request.contextPath}/static/plugins/echarts.min.js"></script>
<script src="${request.contextPath}/static/plugins/echarts-wordcloud.min.js"></script>
<script src="${request.contextPath}/static/js/nums.js"></script>
<script src="${request.contextPath}/static/js/dayjs.min.js"></script>
<script src="${request.contextPath}/static/js/time.js"></script>
<#if isMobile == false>
	<script src="${request.contextPath}/static/plugins/layui/layui.js" charset="utf-8"></script>
</#if>
<script>
    let dailyChart = echarts.init(document.getElementById('dailyChart'))
    let postChart = echarts.init(document.getElementById('postChart'))
    let dailyX7Data = []
    let dailyYFollow7Data = []
    let dailyYLike7Data = []
    let dailyX30Data = []
    let dailyYFollow30Data = []
    let dailyYLike30Data = []
    let dailyX7TotalData = []
    let dailyYFollow7TotalData = []
    let dailyYLike7TotalData = []
    let dailyX30TotalData = []
    let dailyYFollow30TotalData = []
    let dailyYLike30TotalData = []
    let postXData = []
    let postYFollowData = []
    let postYLikeData = []
    let postYReviewData = []
    let postYShareData = []
    let postImg = []
    let postTitle = []
    let postTime = []
    let postX30Data = []
    let postY30FollowData = []
    let postY30LikeData = []
    let postY30ReviewData = []
    let postY30ShareData = []
    let post30Img = []
    let post30Title = []
    let post30Time = []
    let fansPortraitData = {}
    <#if isUnlocked = false>
    <#list weekExampleData.bloggerPerformanceResponse as item>
    dailyX7Data.push(formateToDate(${item.datecode?c}))
    dailyYFollow7Data.push(${item.followerGrowth?c})
    dailyYLike7Data.push(${item.likeGrowth?c})
    dailyYFollow7TotalData.push(${item.followerCount?c})
    dailyYLike7TotalData.push(${item.likeCount?c})
    </#list>
    <#list monthExampleData.bloggerPerformanceResponse as item>
    dailyX30Data.push(formateToDate(${item.datecode?c}))
    dailyYFollow30Data.push(${item.followerGrowth?c})
    dailyYLike30Data.push(${item.likeGrowth?c})
    dailyYFollow30TotalData.push(${item.followerCount?c})
    dailyYLike30TotalData.push(${item.likeCount?c})
    </#list>
    <#setting datetime_format="MM-dd"/>
    <#list weekExampleData.awemeResponse as item>
    postXData.push('${(item.createTime*1000)?number_to_datetime}')
    postImg.push('${item.cover}')
    postTitle.push('${item.title}')
    postTime.push(formatTime((+${item.createTime?c} * 1000), 'MM-DD-YYYY HH:mm:ss'))
    postYFollowData.push(${item.views?c})
    postYLikeData.push(${item.likes?c})
    postYReviewData.push(${item.reviews?c})
    postYShareData.push(${item.shares?c})
    </#list>
    <#list monthExampleData.awemeResponse as item>
    postX30Data.push('${(item.createTime*1000)?number_to_datetime}')
    post30Img.push('${item.cover}')
    post30Title.push('${item.title}')
    postY30FollowData.push(${item.views?c})
    postY30LikeData.push(${item.likes?c})
    postY30ReviewData.push(${item.reviews?c})
    postY30ShareData.push(${item.shares?c})
    </#list>
    <#else>
    <#if isMobile == false>
    getFansPortrait()
    initPostAnalysics()
    </#if>
    </#if>
    let dailySubTabName = 'Growth'
    let options = {
        xAxis: {
            type: 'category',
            data: dailyX7Data,
            boundaryGap: false,
            axisLine: {
                show: false
            },
            axisTick: {
                show: false
            }
        },
        tooltip: {
            trigger: 'axis',
            formatter: (params) => {
                return params[0].name + '<br/>' + dailySubTabName + ': ' + toThousands(+params[0].value)
            }
        },
        grid: {
            top: 16,
            left: 50,
            right: 18,
            bottom: 20,
            borderWidth: 0
        },
        yAxis: {
            type: 'value',
            axisLabel: {
                formatter(val, inx) {
                    return numFormat(val)
                }
            },
            axisLine: {
                show: false
            },
            axisTick: {
                show: false
            },
            splitLine: {
                lineStyle: {
                    type: 'dashed',
                    color: '#D8D8D8'
                }
            }
        },
        series: [{
            data: dailyYFollow7Data,
            type: 'line',
            showSymbol: false,
            smooth: true,
            symbolSize: 8,
            lineStyle: {
                width: 1
            },
            areaStyle: {
                normal: {
                    opacity: 0.3
                }
            },
            itemStyle: {
                normal: {
                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                        offset: 0,
                        color: '#1890FF'
                    }, {
                        offset: 1,
                        color: '#FFF'
                    }]),
                    lineStyle: {
                        color: '#1890FF' // 改变折线颜色
                    }
                }
            }
        }]
    }
    let toolImgData = []
    let toolTitleData = []
    let toolTimeData = []
    let postOptions = {
        color: ['#1890FF'],
        xAxis: {
            type: 'category',
            data: postXData,
            axisLine: {
                show: false
            },
            axisTick: {
                show: false
            }
        },
        tooltip: {
            // formatter: '{b}<br/>{c}'
            formatter: (params) => {
                // type: 1.view 2.like 3.review 4.share
                let str = ''
                <#if isMobile == false>
                str += '<div class="chart-tooltip"><div class="chart-left">' +
                    '<img src="' + toolImgData[params.dataIndex] + '"/></div>'
                </#if>
                str += '<div class="chart-right">'
                <#if isMobile == false>
                str += '<div class="tooltip-top">' + toolTitleData[params.dataIndex] + '</div>'
                str += toolTimeData[params.dataIndex] + ' UTC<br/>'
                <#else>
                str += params.name + '<br/>'
                </#if>
                if (postType === 1) {
                    str += 'Views'
                } else if (postType === 2) {
                    str += 'Likes'
                } else if (postType === 3) {
                    str += 'Reviews'
                } else {
                    str += 'Share'
                }
                str += '：' + toThousands(+params.value) + '</div>'
                <#if isMobile == false>
                str += '</div>'
                </#if>
                return str
            }
        },
        grid: {
            top: 16,
            left: 50,
            right: 0,
            bottom: 20,
            borderWidth: 0
        },
        yAxis: {
            type: 'value',
            axisLabel: {
                formatter(val, inx) {
                    return numFormat(val)
                }
            },
            axisLine: {
                show: false
            },
            axisTick: {
                show: false
            },
            splitLine: {
                lineStyle: {
                    type: 'dashed',
                    color: '#D8D8D8'
                }
            }
        },
        series: [{
            data: dailyYFollow7Data,
            type: 'bar',
            lineStyle: {
                width: 1
            },
            areaStyle: {
                normal: {
                    opacity: 0.3
                }
            },
            // barWidth: 6,
            itemStyle: {
                barBorderRadius: [4, 4, 0, 0],
                normal: {
                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                        offset: 0,
                        color: '#1890FF'
                    }, {
                        offset: 1,
                        color: '#FFF'
                    }]),
                    lineStyle: {
                        color: '#1890FF' // 改变折线颜色
                    }
                }
            }
        }]
    }
    // type: 1 follower, 2: like
    let dailyType = 1
    let dailySubTab = 0
    var currentDay = 7

    function setDailyChart() {
        dailyChart.clear()
        if (currentDay !== 7) {
            options.xAxis.data = dailyX30Data
            // 判断分类
            if (dailyType === 1) {
                // 判断是否是growth
                if (dailySubTab === 0) {
                    options.series[0].data = dailyYFollow30Data
                } else {
                    options.series[0].data = dailyYFollow30TotalData
                }
            } else {
                // 判断是否是growth
                if (dailySubTab === 0) {
                    options.series[0].data = dailyYLike30Data
                } else {
                    options.series[0].data = dailyYLike30TotalData
                }
            }
        } else {
            options.xAxis.data = dailyX7Data
            if (dailyType === 1) {
                if (dailySubTab === 0) {
                    options.series[0].data = dailyYFollow7Data
                } else {
                    options.series[0].data = dailyYFollow7TotalData
                }
            } else {
                if (dailySubTab === 0) {
                    options.series[0].data = dailyYLike7Data
                } else {
                    options.series[0].data = dailyYLike7TotalData
                }
            }
        }
        dailyChart.setOption(options, true)
    }

    // type: 1.view 2.like 3.review 4.share
    let postType = 1

    function setPostChart() {
        postChart.clear()
        <#if isMobile == true>
        postOptions.xAxis.data = postXData
        toolImgData = postImg
        toolTimeData = postTime
        toolTitleData = postTitle
        if (postType === 1) {
            postOptions.series[0].data = postYFollowData
        } else if (postType === 2) {
            postOptions.series[0].data = postYLikeData
        } else if (postType === 3) {
            postOptions.series[0].data = postYReviewData
        } else {
            postOptions.series[0].data = postYShareData
        }
        <#else>
        if (currentDay === 7) {
            postOptions.xAxis.data = postXData
            toolImgData = postImg
            toolTimeData = postTime
            toolTitleData = postTitle
            if (postType === 1) {
                postOptions.series[0].data = postYFollowData
            } else if (postType === 2) {
                postOptions.series[0].data = postYLikeData
            } else if (postType === 3) {
                postOptions.series[0].data = postYReviewData
            } else {
                postOptions.series[0].data = postYShareData
            }
        } else {
            postOptions.xAxis.data = postX30Data
            toolImgData = post30Img
            toolTimeData = post30Time
            toolTitleData = post30Title
            if (postType === 1) {
                postOptions.series[0].data = postY30FollowData
            } else if (postType === 2) {
                postOptions.series[0].data = postY30LikeData
            } else if (postType === 3) {
                postOptions.series[0].data = postY30ReviewData
            } else {
                postOptions.series[0].data = postY30ShareData
            }
        }
        </#if>
        postChart.setOption(postOptions, true)
    }

    function checkUnlockPermission(tabInx = 0) {
        <#if isMobile == false>
        let elTab = document.querySelector('.wrap-tab .tab-con-' + tabInx)
        elTab.showLoading()
        <#else>
        showLoading()
        </#if>

        let _this = this
        _axios.get('/v1/blogger/report/unlock/checked').then(res => {
            if (res.Code === 200) {
                let extra = ''
                let isShowAgain = !localStorage.getItem('isShowAgain')
                if (res.Data) {
                    if (res.Data.type === 1) {
                        if (isShowAgain) {
                            extra = '<div class="tips"><input type="checkbox"/><span>Do not show this message again.</span></div>'
                        } else {
                            unlockReport()
                            return
                        }
                    }
                    showModal({
                        content: res.Msg + extra,
                        confirmBtn: {
                            event: this.unlockReport.bind(_this, res.Data.type)
                        }
                    })
                } else {
                    window.location.href = '${contextPath}/pricing'
                }
            } else {
                showToast(res.Msg)
            }
            <#if isMobile == false>
            elTab.hideLoading()
            <#else>
            hideLoading()
            </#if>

        })
    }

    function unlockReport(type) {
        showLoading()
        if (type === 1) {
            let checkbox = document.querySelector('.modal input')
            if (checkbox.checked) {
                localStorage.setItem('isShowAgain', 1)
            } else {
                localStorage.removeItem('isShowAgain')
            }
        }
        closeModal()
        _axios.post('/v1/blogger/report/unlock', {
            uid: '${blogger.uid?c}'
        }).then(res => {
            hideLoading()
            if (res && res.Code === 200) {
                window.location.reload()
            }
        })
    }

    // 粉丝画像
    function getFansPortrait() {
        let e = document.querySelector('.tab-con-2')
        e.showLoading()
        _axios.get('/v1/blogger/fansPortrait/${blogger.uid?c}').then(res => {
            if (res.Code === 200) {
                fansPortraitData = res.Data
                getGenderChart(res.Data.genderDistribution)
                getAgeChart(res.Data.ageDistribution)
                // getRatioChart(res.Data.active)
                getPeriodChart()
                getRegionChart(res.Data.regionDistribution)
                getLanguage(res.Data.languageDistribution)
            }
            e.hideLoading()
        })
    }

    function getGenderChart(data) {
        let e = document.getElementById('genderChart')
        if (data) {
            let genderConfig = {
                color: ['#3AA0FF', '#F56C6C'],
                tooltip: {
                    trigger: 'item',
                    formatter: '{b}: {d}%'
                },
                series: [
                    {
                        name: 'gender',
                        type: 'pie',
                        radius: ['50%', '70%'],
                        avoidLabelOverlap: false,
                        label: {
                            show: false,
                            position: 'center'
                        },
                        // emphasis: {
                        //     label: {
                        //         show: true,
                        //         fontSize: '30',
                        //         fontWeight: 'bold'
                        //     }
                        // },
                        labelLine: {
                            show: false
                        },
                        data: data.map(item => {
                            return {
                                value: item.value,
                                name: item.property
                            }
                        })
                    }
                ]
            }
            let chart = echarts.init(e)
            chart.setOption(genderConfig)
            chart.resize({
                width: $('#genderChart').width()
            })
            $('#genderChart').append('<div class="center">' +
                '<div class="item">' +
                '<i class="iconfont iconsingle-female2"></i>' +
                data[1].value + '%' +
                '</div>' +
                '<div class="item">' +
                '<i class="iconfont iconsingle-male1"></i>' +
                data[0].value + '%' +
                '</div>' +
                '</div>')
        } else {
            showNoData(e)
        }
    }

    function getAgeChart(data) {
        let e = document.getElementById('ageChart')
        if (data) {
            let ageConfig = {
                color: ['#D3E9FF', '#3AA0FF', '#62B2FE', '#89C5FF', '#B1D9FF', '#D8ECFF'],
                tooltip: {
                    trigger: 'item',
                    formatter: '{b}: {d}%'
                },
                series: [
                    {
                        name: 'age',
                        type: 'pie',
                        <#if isMobile == false>
                        radius: ['50%', '70%'],
                        <#else>
                        radius: ['35%', '50%'],
                        </#if>
                        data: data.map(item => {
                            return {
                                value: item.value,
                                name: item.property
                            }
                        })
                    }
                ]
            }
            let chart = echarts.init(e)
            chart.setOption(ageConfig)
            chart.resize({
                width: $('#ageChart').width()
            })
        } else {
            showNoData(e)
        }
    }

    function getRatioChart(data) {
        let e = document.getElementById('ratioChart')
        let ratioConfig = {
            color: ['#D8ECFF', '#3AA0FF'],
            tooltip: {
                trigger: 'item',
                formatter: '{a} <br/>{b}: {c} ({d}%)'
            },
            series: [
                {
                    name: 'gender',
                    type: 'pie',
                    radius: ['50%', '70%'],
                    data: [
                        {value: data, name: 'Active'},
                        {value: +(1 - data), name: 'Inactive'},
                    ]
                }
            ]
        }
        let chart = echarts.init(e)
        chart.clear()
        chart.setOption(ratioConfig)
    }

    let week_name = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]

    function getPeriodChart() {
        let periodConfig_day = null
        let chart1 = document.getElementById('periodChart1')
        if (fansPortraitData.activeDayDistribution) {
            periodConfig_day = {
                color: ['#1890FF'],
                xAxis: {
                    type: 'category',
                    data: fansPortraitData.activeDayDistribution.map((item, index) => index),
                    axisLine: {
                        show: false
                    },
                    axisTick: {
                        show: false
                    }
                },
                tooltip: {
                    formatter: '{b}:00<br/>Proportion：{c}%'
                },
                <#if isMobile == false>
                grid: {
                    top: 16,
                    left: 32,
                    right: 0,
                    bottom: 20,
                    borderWidth: 0
                },
                <#else>
                grid: {
                    top: 32,
                    left: 50,
                    right: 16,
                    bottom: 32,
                    borderWidth: 0
                },
                </#if>
                yAxis: {
                    type: 'value',
                    axisLabel: {
                        formatter(val, inx) {
                            return val + '%'
                        }
                    },
                    axisLine: {
                        show: false
                    },
                    axisTick: {
                        show: false
                    },
                    splitLine: {
                        lineStyle: {
                            type: 'dashed',
                            color: '#D8D8D8'
                        }
                    }
                },
                series: [{
                    data: fansPortraitData.activeDayDistribution,
                    type: 'bar',
                    lineStyle: {
                        width: 1
                    },
                    areaStyle: {
                        normal: {
                            opacity: 0.3
                        }
                    },
                    // barWidth: 6,
                    itemStyle: {
                        barBorderRadius: [4, 4, 0, 0],
                        normal: {
                            color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                offset: 0,
                                color: '#1890FF'
                            }, {
                                offset: 1,
                                color: '#FFF'
                            }]),
                            lineStyle: {
                                color: '#1890FF' // 改变折线颜色
                            }
                        }
                    }
                }]
            }
            let chart_day = echarts.init(chart1)
            chart_day.setOption(periodConfig_day)
            chart_day.resize({
                width: $('#periodChart1').width()
            })
        } else {
            showNoData(chart1)
        }
        let periodConfig_week = null
        let chart2 = document.getElementById('periodChart2')
        if (fansPortraitData.activeWeekDistribution) {
            periodConfig_week = {
                color: ['#1890FF'],
                xAxis: {
                    type: 'category',
                    data: fansPortraitData.activeWeekDistribution.map((item, index) => week_name[index]),
                    axisLine: {
                        show: false
                    },
                    axisTick: {
                        show: false
                    }
                },
                tooltip: {
                    formatter: '{b}<br/>Proportion：{c}%'
                },
                <#if isMobile == false>
                grid: {
                    top: 16,
                    left: 32,
                    right: 0,
                    bottom: 20,
                    borderWidth: 0
                },
                <#else>
                grid: {
                    top: 32,
                    left: 50,
                    right: 16,
                    bottom: 32,
                    borderWidth: 0
                },
                </#if>
                yAxis: {
                    type: 'value',
                    axisLabel: {
                        formatter(val) {
                            return val + '%'
                        }
                    },
                    axisLine: {
                        show: false
                    },
                    axisTick: {
                        show: false
                    },
                    splitLine: {
                        lineStyle: {
                            type: 'dashed',
                            color: '#D8D8D8'
                        }
                    }
                },
                series: [{
                    data: fansPortraitData.activeWeekDistribution,
                    type: 'bar',
                    lineStyle: {
                        width: 1
                    },
                    areaStyle: {
                        normal: {
                            opacity: 0.3
                        }
                    },
                    // barWidth: 6,
                    itemStyle: {
                        barBorderRadius: [4, 4, 0, 0],
                        normal: {
                            color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                                offset: 0,
                                color: '#1890FF'
                            }, {
                                offset: 1,
                                color: '#FFF'
                            }]),
                            lineStyle: {
                                color: '#1890FF' // 改变折线颜色
                            }
                        }
                    }
                }]
            }
            let chart_week = echarts.init(chart2)
            chart_week.setOption(periodConfig_week)
            chart_week.resize({
                width: $('#periodChart2').width()
            })
        } else {
            showNoData(chart2)
        }
    }

    function getRegionChart(data) {
        let e = document.getElementById('regionChart')
        if (data && data.length > 0) {
            let str = ''
            data.map((item, inx) => {
                let percent = item.value + '%'
                str += '<div class="region-item">' +
                    '<div class="label">' +
                    '<div class="left">' + item.property + '</div><div class="right">' + percent + '</div>' +
                    '</div>' +
                    '<div class="progress">'
                if (inx === 0) {
                    str += '<div class="progress-bar" style="width:' + percent + ';background: #3AA0FF;"></div>'
                } else if (inx === 1) {
                    str += '<div class="progress-bar" style="width:' + percent + ';background: #F56C6C;"></div>'
                } else if (inx === 2) {
                    str += '<div class="progress-bar" style="width:' + percent + ';background: #FFBD5A;"></div>'
                } else if (inx === 3) {
                    str += '<div class="progress-bar" style="width:' + percent + ';background: #8267F1;"></div>'
                } else {
                    str += '<div class="progress-bar" style="width:' + percent + ';background: #1FDBBE;"></div>'
                }
                str += '</div>' + '</div>'
            })
            e.innerHTML = str
        } else {
            showNoData(e)
        }
    }

    // post analytics
    function initPostAnalysics() {
        <#if isMobile == false>
        document.querySelector('.tab-con-3').showLoading()
        <#else>
        document.querySelector('.tab-con-1').showLoading()
        </#if>
        getHashTag()
        getPostActivity()
        getUsedSounds()
        getCommercical()
        getMentioned()
    }

    function getHashTag() {
        let option = {
            tooltip: {
                formatter: '{b}<br/>Usage Count：{c}'
            },
            series: [{
                type: 'wordCloud',
                shape: 'circle',
                // maskImage: maskImage,
                left: 'center',
                top: 'center',
                // width: '70%',
                // height: '80%',
                right: null,
                bottom: null,
                sizeRange: [12, 30],
                rotationRange: [0, 0],
                rotationStep: 0,
                gridSize: 15,
                drawOutOfBound: false,
                textStyle: {
                    normal: {
                        fontFamily: 'DM Sans',
                        color: '#1890FF'
                    }
                },
                data: []
            }]
        }
        _axios.get('/v1/blogger/hashtag/all/${blogger.uid?c}').then(res => {
            if (res.Code === 200) {
                let e = document.getElementById('hashtagsChart')
                if (res.Data.length > 0) {
                    let cloudData = res.Data.map(item => {
                        return {
                            name: '#' + item.hashtagName,
                            value: item.mention
                        }
                    })
                    option.series[0].data = cloudData
                    let chart = echarts.init(e)
                    chart.setOption(option)
                    chart.resize({
                        width: $('#hashtagsChart').width()
                    })
                } else {
                    showNoData(e)
                }
            }
        })
    }

    function getPostActivity() {
        let options = {
            color: ['#1890FF'],
            xAxis: {
                type: 'category',
                data: [],
                axisLine: {
                    show: false
                },
                axisTick: {
                    show: false
                }
            },
            tooltip: {
                formatter: '{b}<br/>Proportion：{c}%'
            },
            grid: {
                top: 16,
                left: 32,
                right: 0,
                bottom: 20,
                borderWidth: 0
            },
            yAxis: {
                type: 'value',
                axisLabel: {
                    formatter(val, inx) {
                        return val + '%'
                    }
                },
                axisLine: {
                    show: false
                },
                axisTick: {
                    show: false
                },
                splitLine: {
                    lineStyle: {
                        type: 'dashed',
                        color: '#D8D8D8'
                    }
                }
            },
            series: [{
                data: [],
                type: 'bar',
                lineStyle: {
                    width: 1
                },
                areaStyle: {
                    normal: {
                        opacity: 0.3
                    }
                },
                // barWidth: 6,
                itemStyle: {
                    barBorderRadius: [4, 4, 0, 0],
                    normal: {
                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                            offset: 0,
                            color: '#1890FF'
                        }, {
                            offset: 1,
                            color: '#FFF'
                        }]),
                        lineStyle: {
                            color: '#1890FF' // 改变折线颜色
                        }
                    }
                }
            }]
        }
        _axios.get('/v1/blogger/aweme/week/${blogger.uid?c}').then(res => {
            if (res.Code === 200) {
                let e = document.getElementById('daysPostChart')
                if (res.Data.length > 0) {
                    options.xAxis.data = week_name
                    options.series[0].data = res.Data.map(item => item.count)
                    let chart = echarts.init(e)
                    chart.setOption(options)
                    chart.resize({
                        <#if isMobile == false>
                        width: $('#daysPostChart').width()
                        <#else>
                        width: $('#hoursPostChart').width()
                        </#if>
                    })
                } else {
                    showNoData(e)
                }
            }
        })
        _axios.get('/v1/blogger/aweme/hour/${blogger.uid?c}').then(res => {
            if (res.Code === 200) {
                let e = document.getElementById('hoursPostChart')
                if (res.Data.length > 0) {
                    options.xAxis.data = res.Data.map(item => item.time + ':00')
                    options.series[0].data = res.Data.map(item => item.count)
                    let chart = echarts.init(e)
                    chart.setOption(options)
                    chart.resize({
                        width: $('#hoursPostChart').width()
                    })
                } else {
                    showNoData(e)
                }
            }
        })
    }

    <#if isMobile == false>
    layui.use('laypage', function () {
        let laypage = layui.laypage;
        //执行一个laypage实例
        laypage.render({
            elem: 'pagination', //注意，这里的 test1 是 ID，不用加 # 号
            count: ${videoTotalSize}, //数据总数，从服务端得到
            prev: '<i class="iconfont iconicon_previous"></i>',
            next: '<i class="iconfont iconarrowright"></i>',
            jump: (obj, first) => {
                if (!first) {
                    page = obj.curr
                    getVideos()
                }
            }
        })
    })
    window.onload = () => {
        <#if isUnlocked == true>
        getDailyTrend()
        getPostTrend()
        getBloggerData()
        <#else>
        init()
        </#if>
    }
    let isExp = false

    function init() {
        setDailyChart()
        setPostChart()
    }

    // Active Time Period 时间切换
    /*function changeTime(e,type){
				if(type === 0) {
						e.classList.add('is-active')
						e.nextElementSibling.nextElementSibling.classList.remove('is-active')
						getPeriodChart(fansPortraitData.activeDayDistribution)
				} else {
						e.classList.add('is-active')
						e.previousElementSibling.previousElementSibling.classList.remove('is-active')
						getPeriodChart(fansPortraitData.activeWeekDistribution)
				}
		}*/
    function changeDayTab(el, index) {
        if (index === 0) {
            currentDay = 7
            document.querySelector('.data-table.tb-7').show()
            document.querySelector('.data-table.tb-30').hide()
        } else {
            currentDay = 30
            document.querySelector('.data-table.tb-7').hide()
            document.querySelector('.data-table.tb-30').show()
        }
        el.parentNode.querySelectorAll('div').forEach((item, inx) => {
            if (inx === index) {
                item.classList.add('is-active')
            } else {
                item.classList.remove('is-active')
            }
        })

        if (isExp) {
            setPostChart()
            setDailyChart()
        } else {
            getBloggerData()
            getDailyTrend()
            getPostTrend()
        }
    }

    function changetab(index) {
        let tabs = document.querySelectorAll('.wrap-tab .tab-item')
        tabs.forEach((e, i) => {
            let tabCon = document.querySelectorAll('.wrap-tab .tab-con-' + i)[0]
            if (i === index) {
                e.classList.add('is-active')
                tabCon.show()
            } else {
                e.classList.remove('is-active')
                tabCon.hide()
            }
        })
    }

    let isShowCard = true

    function changeShowType(type) {
        isShowCard = !type
        document.querySelectorAll('.wrap-tab .sort-tab.right>div').forEach((item, index) => {
            if (type === index) {
                item.classList.add('is-active')
            } else {
                item.classList.remove('is-active')
            }

        })
        document.querySelectorAll('.wrap-tab .wrap-tiktoker').forEach((item, index) => {
            if (index === type) {
                item.show('grid')
            } else {
                item.hide()
            }
        })
    }

    let sort = 1
    let page = 1

    function getVideos() {
        if (isShowCard) {
            document.getElementById('cardList').showLoading()
        } else {
            document.getElementById('tableList').showLoading()
        }
        let data = {
            infoType: 2,
            page: page,
            sort: sort,
            pageSize: 10
        }
        let url = getEncodeUrl('/v1/blogger/aweme/list/${blogger.uid?c}', data)
        _axios.get(url).then(res => {
            if (res.Code === 200) {
                document.getElementById('cardList').innerHTML = ''
                document.querySelector('#tableList tbody').innerHTML = ''
                res.Data.ItemList.forEach(item => {
                    $('#cardList').append('<a href="' + item.shareUrl + '" target="_blank">' +
                        '<div class="card-item">' +
                        '<img src="' + item.cover + '">' +
                        '<div class="bottom">' +
                        '<i class="iconfont iconic_play"></i>' +
                        numFormat(item.views) + '</div></div></a>')

                    let str = '<tr>' +
                        '<td>' +
                        '<div class="td-inx">'
                    if (item.score >= 90) {
                        str += '<i class="iconfont iconhuo red">'
                    } else if (item.score < 90 && item.score >= 80) {
                        str += '<i class="iconfont iconhuo orange">'
                    } else if (item.score < 80 && item.score >= 70) {
                        str += '<i class="iconfont iconhuo green">'
                    } else {
                        str += '<i class="iconfont iconhuo gray">'
                    }
                    str += '<span>' + (+item.score.toFixed(1)) + '</span>' + '</i></div>'
                    str += '</td>' +
                        '<td class="tb-tiktoker">' +
                        '<div>' +
                        '<img src="' + item.cover + '" />' +
                        '<div class="video-time">' + formatSeceondTimeVideo(+item.duration) + '</div>' +
                        '</div>' +
                        '<div>' +
                        '<div class="tb-name" title="' + item.title + '">' +
                        item.title +
                        '</div>' +
                        '<div class="bottom">' +
                        '<div class="time">' + dateTimeFormat(item.createTime) + '</div>' +
                        ' </div>' +
                        ' </div>' +
                        ' </td>' +
                        '<td align="center">' + numFormat(item.views) + '</td>' +
                        '<td align="center">' + numFormat(item.likes) + '</td>' +
                        '<td align="center">' + numFormat(item.reviews) + '</td>' +
                        '<td align="center">' + numFormat(item.shares) + '</td>'
                    str += '<td align="center">' + item.engagementRate + '%</td>' +
                        '<td>' +
                        '<div class="td-action">' +
                        '<div class="green">' +
                        '   <a href="' + item.shareUrl + '">' +
                        '       <i class="iconfont iconbofang-copy" title="play"></i>' +
                        '   </a>' +
                        '</div>' +
                        '</div>' +
                        '</td>' +
                        '</tr>'
                    $('#tableList tbody').append(str)
                })
            } else if (res.Code === 403) {
                let e = document.querySelector('.permission-tips')
                e.show()
                e.innerHTML = res.Msg
                checkUnlockPermission()
            }
            if (isShowCard) {
                document.getElementById('cardList').hideLoading()
            } else {
                document.getElementById('tableList').hideLoading()
            }
        })
    }

    function changeOrder(type) {
        <#if login == false>
            toLogin()
	        return false
        </#if>
        if (sort !== (type + 1)) {
            sort = type + 1
            getVideos()
        }
        document.querySelectorAll('.wrap-tab .sort-tab.left>div').forEach((item, index) => {
            if (type === index) {
                item.classList.add('is-active')
            } else {
                item.classList.remove('is-active')
            }
        })
    }

    function showExp() {
        isExp = true
        document.getElementById('expImg').hide()
        document.querySelector('.tab-con-1 .overflow').hide()
        document.getElementById('data-exm').show()
    }

    function showDemoImg(e) {
        isExp = true
        let demo = e.parentNode.parentNode.parentNode
        demo.querySelector('.overflow').hide()
        demo.querySelector('.tips').show('flex')
    }

    function changeDailySubTab(el, index) {
        el.parentNode.querySelectorAll('li').forEach((item, inx) => {
            if (inx === index) {
                item.classList.add('is-active')
                dailySubTab = inx
                if (inx === 0) {
                    dailySubTabName = 'Growth'
                } else {
                    dailySubTabName = 'Total'
                }
            } else {
                item.classList.remove('is-active')
            }
        })
        setDailyChart()
    }

    function changeChartTab(el, index) {
        el.parentNode.querySelectorAll('li').forEach((item, inx) => {
            if (inx === index) {
                item.classList.add('is-active')
            } else {
                item.classList.remove('is-active')
            }
        })
        if (el.parentNode.getAttribute('id')) {
            dailyType = index + 1
            setDailyChart()
        } else {
            postType = index + 1
            setPostChart()
        }
    }

    function getBloggerData() {
        let e = document.querySelector('.tab-con-1')
        e.showLoading()
        let infoType = 1
        if (currentDay !== 7) {
            infoType = 2
        }
        _axios.get('/v1/blogger/report/${blogger.uid?c}/' + infoType).then(res => {
            if (res.Code === 200) {
                let data = res.Data
                let str = '<tr>' +
                    ' <td>Current period:</td>' +
                    '<td>' +
                    '<div class="data-item">' +
                    '<div>' + data.recentPosts
                '</div>'
                if (data.percentPosts > 0) {
                    str += '<div class="growth up">'
                } else {
                    str += '<div class="growth down">'
                }
                str += data.percentPosts + '%' +
                    ' <span><i class="iconfont iconbofang-copy"></i></span>' +
                    '</div>' +
                    '</div>' +
                    '</td>' +
                    '<td>' +
                    '<div class="data-item">' +
                    '<div>' + numFormat(data.recentFollowerGrowth) +
                    '</div>'
                if (data.percentFollowerGrowth > 0) {
                    str += '<div class="growth up">'
                } else {
                    str += '<div class="growth down">'
                }
                str += data.percentFollowerGrowth + '%' +
                    '<span><i class="iconfont iconbofang-copy"></i></span>' +
                    '</div>' +
                    '</div>' +
                    '</td>' +
                    '<td>' +
                    '<div class="data-item">' +
                    '<div>' + numFormat(data.recentLikesGrowth) +
                    '</div>'
                if (data.percentLikesGrowth > 0) {
                    str += '<div class="growth up">'
                } else {
                    str += '<div class="growth down">'
                }
                str += data.percentLikesGrowth + '%' +
                    '<span><i class="iconfont iconbofang-copy"></i></span>' +
                    '                                                        </div>' +
                    '                                                    </div>' +
                    '                                            </td>' +
                    '                                        </tr>' +
                    '                                        <tr>' +
                    '                                            <td>Last period:</td>' +
                    '                                            <td>' +
                    data.lastPosts +
                    '                                            </td>' +
                    '                                            <td>' +
                    numFormat(data.lastFollowerGrowth) +
                    '                                            </td>' +
                    '                                            <td>' +
                    numFormat(data.lastLikesGrowth)
                '                                            </td>' +
                '                                        </tr>'
                if (infoType === 1) {
                    document.getElementById('unlockData0').innerHTML = str
                } else {
                    document.getElementById('unlockData2').innerHTML = str
                }
            }
            e.hideLoading()
        })
    }

    function getDailyTrend() {
        let infoType = 1
        if (currentDay !== 7) {
            infoType = 2
        }
        _axios.get('/v1/blogger/performance/${blogger.uid?c}/' + infoType).then(res => {
            if (res && res.Code === 200) {
                let e = document.getElementById('dailyChart')
                if (res.Data.length > 0) {
                    if (infoType === 1) {
                        dailyX7Data = res.Data.map(item => formateToDate(item.datecode))
                        dailyYFollow7Data = res.Data.map(item => item.followerGrowth)
                        dailyYLike7Data = res.Data.map(item => item.likeGrowth)
                        dailyYFollow7TotalData = res.Data.map(item => item.followerCount)
                        dailyYLike7TotalData = res.Data.map(item => item.likeCount)
                    } else {
                        dailyX30Data = res.Data.map(item => formateToDate(item.datecode))
                        dailyYFollow30Data = res.Data.map(item => item.followerGrowth)
                        dailyYLike30Data = res.Data.map(item => item.likeGrowth)
                        dailyYFollow30TotalData = res.Data.map(item => item.followerCount)
                        dailyYLike30TotalData = res.Data.map(item => item.likeCount)
                    }
                    setDailyChart()
                } else {
                    showNoData(e)
                }
            }
            hideLoading()
        })
    }

    function getPostTrend() {
        let infoType = 1
        if (currentDay !== 7) {
            infoType = 2
        }
        _axios.get('/v1/blogger/report/aweme/performance/${blogger.uid?c}/' + infoType).then(res => {
            if (res && res.Code === 200) {
                let e = document.getElementById('postChart')
                if (res.Data.length > 0) {
                    if (infoType === 1) {
                        postXData = res.Data.map(item => dateFormat(item.createTime))
                        postTitle = res.Data.map(item => item.title)
                        postImg = res.Data.map(item => item.cover)
                        postTime = res.Data.map(item => formatTime(+item.createTime, 'MM-DD-YYYY HH:mm:ss'))
                        postYFollowData = res.Data.map(item => item.views)
                        postYLikeData = res.Data.map(item => item.likes)
                        postYReviewData = res.Data.map(item => item.reviews)
                        postYShareData = res.Data.map(item => item.shares)
                    } else {
                        postX30Data = res.Data.map(item => dateFormat(item.createTime))
                        post30Title = res.Data.map(item => item.title)
                        post30Img = res.Data.map(item => item.cover)
                        post30Time = res.Data.map(item => formatTime(+item.createTime, 'MM-DD-YYYY HH:mm:ss'))
                        postY30FollowData = res.Data.map(item => item.views)
                        postY30LikeData = res.Data.map(item => item.likes)
                        postY30ReviewData = res.Data.map(item => item.reviews)
                        postY30ShareData = res.Data.map(item => item.shares)
                    }
                    setPostChart()
                } else {
                    showNoData(e)
                }
            }
        })
    }

    function getLanguage(data) {
        if (data && data.length > 0) {
            let pies = document.querySelectorAll('#languageCon .pie-num')
            let piesTx = document.querySelectorAll('#languageCon .pie-tx')
            data.forEach((item, index) => {
                pies[index].innerText = ((+item.value).toFixed(2) + '%')
                loadPercent((+item.value).toFixed(2), 100, index)
                piesTx[index].innerText = item.property
            })
        } else {
            let e = document.getElementById('languageCon')
            e.innerHTML = ''
            showNoData(e)
        }
    }

    function loadPercent(x, y, index) {
        var rotate = (x / y) * 360
        var rotateRight = 0
        var rotateLeft = 0
        if (rotate < 180) {
            rotateRight = rotate + (-45)
        } else {
            rotateRight = 135
            rotateLeft = (rotate - 180 - 45)
            $("#loop-lc-" + index).css({
                "-webkit-transform": "rotate(" + rotateLeft + "deg)",
            })
        }
        $("#loop-rc-" + index).css({
            "-webkit-transform": "rotate(" + rotateRight + "deg)",
        })
    }

    function getUsedSounds() {
        _axios.get('/v1/blogger/music/${blogger.uid?c}').then(res => {
            if (res.Code === 200) {
                let e = document.querySelector('#postSound tbody')
                if (res.Data.length > 0) {
                    let str = ''
                    res.Data.map(item => {
                        str += '<tr>' +
                            '<td class="sound-info">' +
                            '<img src="${request.contextPath}/static/img/Music.png">' +
                            '<div><div>' + item.title + '</div><div>' + item.author + '</div></div>' +
                            '</td>' +
                            '<td> ' + item.mention + '</td>' +
                            '<td> ' + numFormat(+item.avgView) + '</td>' +
                            '<td> ' + (+item.engagementRate).toFixed(1) + '%</td>' +
                            '<td class="performance">'
                        if (item.performance > 20) {
                            str += '<span class="success">Excellent</span>'
                        } else if (item.performance < -20) {
                            str += '<span class="error">Poor</span>'
                        } else {
                            str += '<span class="info">Average</span>'
                        }
                        str += '</td></tr>'
                    })
                    e.innerHTML = str
                } else {
                    $('#postSound').height('350px')
                    showNoData(e)
                }
            }
        })
    }

    function getCommercical() {
        _axios.get('/v1/blogger/hashtag/${blogger.uid?c}').then(res => {
            if (res.Code === 200) {
                let e = document.querySelector('#postCommercial tbody')
                if (res.Data.length > 0) {
                    let str = ''
                    res.Data.map(item => {
                        str += '<tr>' +
                            '<td class="sound-info">' +
                            '<img src="${request.contextPath}/static/img/Hashtag1.png">' +
                            '<div>' + item.hashtagName + '</div>' +
                            '</td>' +
                            '<td> ' + item.mention + '</td>' +
                            '<td> ' + numFormat(+item.avgView) + '</td>' +
                            '<td> ' + (+item.engagementRate).toFixed(1) + '%</td>' +
                            '<td class="performance">'
                        if (item.performance > 20) {
                            str += '<span class="success">Excellent</span>'
                        } else if (item.performance < -20) {
                            str += '<span class="error">Poor</span>'
                        } else {
                            str += '<span class="info">Average</span>'
                        }
                        str += '</td></tr>'
                    })
                    e.innerHTML = str
                } else {
                    showNoData(e, 350)
                }
            }
        })
    }

    function getMentioned(stats = 1, changeThis = false) {
        _axios.get('/v1/blogger/mention/${blogger.uid?c}/' + stats).then(res => {
            if (res.Code === 200) {
                let e = document.querySelector('#postMentioned tbody')
                let str = ''
                if (res.Data.length > 0) {
                    res.Data.map(item => {
                        str += '<tr>' +
                            '<td class="mentioned-info">' +
                            '<div class="avatar"><img src="' + item.avatar + '">'
                        if (item.enterpriseVerifyReason && item.customVerify) {
                            str += '<i class="iconfont iconzhichi"></i>'
                        }
                        str += '</div>' +
                            '<div><div>' + item.nickname + '</div><div>' + item.uniqueId + '</div></div>' +
                            '</td>' +
                            '<td> ' + item.mention + '</td>' +
                            '<td> ' + numFormat(+item.avgView) + '</td>' +
                            '<td> ' + (+item.engagementRate).toFixed(1) + '%</td>' +
                            '<td class="performance">'
                        if (item.performance > 20) {
                            str += '<span class="success">Excellent</span>'
                        } else if (item.performance < -20) {
                            str += '<span class="error">Poor</span>'
                        } else {
                            str += '<span class="info">Average</span>'
                        }
                        str += '</td></tr>'
                    })
                    e.innerHTML = str
                } else {
                    e.innerHTML = str
                    showNoData(e, 350)
                }
            }
            if (!changeThis) {
                document.querySelector('.tab-con-3').hideLoading()
            } else {
                document.getElementById('postMentioned').hideLoading()
            }
        })
    }

    <#else>
    window.onload = () => {
        init()
    }

    function init() {
        setDailyChart()
        setPostChart()
        initEvent()
    }

    </#if>
</script>
</body>
</html>
